_P_a_t_c_h will take a patch file containing any of the four forms of
difference listing produced by the _d_i_f_f program and apply those
differences to an original file, producing a patched version. By
default, the patched version is put in place of the original, with the
original file backed up to the same name with the extension ".orig" ("~"
on systems that do not support long file names), or as specified by the
----bbbb, ----BBBB (--------pppprrrreeeeffffiiiixxxx), or ----VVVV (--------vvvveeeerrrrssssiiiioooonnnn----ccccoooonnnnttttrrrroooollll) options. The extension used
for making backup files may also be specified in the SSSSIIIIMMMMPPPPLLLLEEEE____BBBBAAAACCCCKKKKUUUUPPPP____SSSSUUUUFFFFFFFFIIIIXXXX
environment variable, which is overridden by the above options.
If the backup file already exists, ppppaaaattttcccchhhh creates a new backup file name
by changing the first lowercase letter in the last component of the
file's name into uppercase. If there are no more lowercase letters in
the name, it removes the first character from the name. It repeats this
process until it comes up with a backup file that does not already exist.
You may also specify where you want the output to go with a ----oooo (--------oooouuuuttttppppuuuutttt)
option; if that file already exists, it is backed up first.
If _p_a_t_c_h_f_i_l_e is omitted, or is a hyphen, the patch will be read from
standard input.
Upon startup, patch will attempt to determine the type of the diff
listing, unless over-ruled by a ----cccc (--------ccccoooonnnntttteeeexxxxtttt), ----eeee (--------eeeedddd), ----nnnn (--------nnnnoooorrrrmmmmaaaallll),
or ----uuuu (--------uuuunnnniiiiffffiiiieeeedddd) option. Context diffs (old-style, new-style, and
unified) and normal diffs are applied by the _p_a_t_c_h program itself, while
_e_d diffs are simply fed to the _e_d editor via a pipe.
_P_a_t_c_h will try to skip any leading garbage, apply the diff, and then skip
any trailing garbage. Thus you could feed an article or message
containing a diff listing to _p_a_t_c_h, and it should work. If the entire
diff is indented by a consistent amount, this will be taken into account.
With context diffs, and to a lesser extent with normal diffs, _p_a_t_c_h can
detect when the line numbers mentioned in the patch are incorrect, and
will attempt to find the correct place to apply each hunk of the patch.
As a first guess, it takes the line number mentioned for the hunk, plus
or minus any offset used in applying the previous hunk. If that is not
the correct place, _p_a_t_c_h will scan both forwards and backwards for a set
of lines matching the context given in the hunk. First _p_a_t_c_h looks for a
place where all lines of the context match. If no such place is found,